﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Threading;
using System.Globalization;

namespace GSite.Web.Controllers
{
    public partial class BaseController : Controller
    {
        public BaseController()
        {
        }

        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            if (RouteData.Values.FirstOrDefault().Value != null)
            {
                try
                {
                    Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(RouteData.Values.FirstOrDefault().Value.ToString());
                    Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(RouteData.Values.FirstOrDefault().Value.ToString());
                }
                catch
                {
                    Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
                    Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
                }
            }
        }
    }
}
